package com.deyou.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.deyou.Constants;
import com.deyou.R;
import com.deyou.model.HouseResourceAttrBean;
import com.deyou.model.OrderBean;
import com.deyou.util.GlideImageLoader;
import com.deyou.util.Urls;
import com.zhy.autolayout.utils.AutoUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by yangyuancheng on 2017/6/14.
 */

public class HouseCalenderItemAdapter extends BaseQuickAdapter<HouseResourceAttrBean, HouseCalenderItemAdapter.ViewHolder> {

    private Context mContext;

    public HouseCalenderItemAdapter(Context context) {
        super(R.layout.house_calender_item_layout);
        this.mContext = context;
    }

    @Override
    protected void convert(ViewHolder helper, HouseResourceAttrBean item) {
        if (null != item){
            new GlideImageLoader().displayImage(mContext, Urls.HouseResourceImageBaseUrl + item.resourceMainPic, helper.ivHouse);
            helper.tvHouseIntro.setText(item.resourceName);
            helper.tvRentPrice.setText(Constants.RMB_UNIT + item.resourcePrice);
            if (item.resourceType == 1)
                helper.tvHouseRentalMode.setText("整套-出租");
            else if (item.attribute1 == 2)
                helper.tvHouseRentalMode.setText("独立房间-出租");
            else if (item.attribute1 == 3)
                helper.tvHouseRentalMode.setText("合住房间-出租");
            else
                helper.tvHouseRentalMode.setText("");

        }
    }

    static class ViewHolder extends BaseViewHolder {
        @BindView(R.id.iv_house)
        ImageView ivHouse;
        @BindView(R.id.tv_house_intro)
        TextView tvHouseIntro;
        @BindView(R.id.tv_house_rental_mode)
        TextView tvHouseRentalMode;
        @BindView(R.id.tv_rent_price)
        TextView tvRentPrice;

        ViewHolder(View view) {
            super(view);
            AutoUtils.auto(view);
            ButterKnife.bind(this, view);
        }
    }
}
